/*
 * Copyright (C) 2017 yixun All Rights Reserved.
 * 
 * DepartmentMapper.java
 */
package com.yixun.qfbao.mapper;

import com.yixun.qfbao.model.Department;
import com.yixun.qfbao.model.dto.DepartmentDto;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;
/**
 * [文件名称]<br>
 * DepartmentMapper.java<br>
 * <br>
 * [文件描述]<br>
 * 部门表 mapper<br>
 * <br>
 * [修改记录]<br>
 * 2017-01-04 11:08:07 创建<br>
 * @version 1.00
 */
public interface DepartmentMapper {
    
	/**
	 * 新增 
	 * @param department 新增BEAN信息
	 * @return 操作行数
	 */
	public int add(Department department);
	/**
	 * 删除
	 * @param departmentDto 满足删除的条件
	 * @return 操作行数
	 */
    public int del(DepartmentDto departmentDto);
	/**
	 * 删除
	 * @param ids 待删除的唯一主键拼接的字符串,主键间以,隔开
	 * @return 操作行数
	 */
    public int dels(String ids);
    /**
     * 编辑
     * @param department 需要编辑的BEAN信息
     */
    public int edit(Department department);
    
    /**
     * 	重置weappQrCode
     * @param department 需要编辑的BEAN信息
     */
    public int resetWeappQrcodeByPermissionCode(Department department);
    /**
     * 编辑
     * @param department 需要编辑的BEAN信息
     */
    public int updateByMerchantId(Department department);
    /**
     * 编辑
     * @param ids 需要编辑的BEAN信息
     * @param ids 待编辑的唯一主键拼接的字符串,主键间以,隔开
     * @return 更新行数
     */
    public int edits(@Param("departmentDto")Department department,@Param("ids")String ids);
    /**
     * 搜索总数
     * @param departmentDto 搜索条件
     * @return 符合条件记录总数
     */
	public int count(DepartmentDto departmentDto);
    /**
	 * 搜索 - 支持分页
	 * @param departmentDto blackWhiteList(搜索条件)
	 * @param beginNum 分页开始页不包含
	 * @param endNum 分页结束页不包含
	 * @return 分页数据
	 */
	public List<Department> list(@Param("departmentDto")DepartmentDto departmentDto,@Param("beginNum")int beginNum,@Param("endNum")int endNum);
   
    /**
	 * 搜索 
	 * @param departmentDto blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<Department> selectListByDto(@Param("departmentDto")DepartmentDto departmentDto);

	public List<Department> selectAllListByDto(@Param("departmentDto")DepartmentDto departmentDto);

	/**
	 * 转移部门时只搜索两级部门
	 * @method: selectchangeListByDto
	 * @param: [departmentDto]
	 * @return: 分页数据
	 */
	public List<Department> selectchangeListByDto(@Param("departmentDto") DepartmentDto departmentDto);

	/**
	 * 搜索 
	 * @param departmentDto blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<DepartmentDto> selectList(@Param("departmentDto")DepartmentDto departmentDto);
	
    /**
	 * 搜索 - 支持分页
	 * @param departmentDto blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public Department selectByDto(@Param("departmentDto")DepartmentDto departmentDto);
	
	/**
	 * @param id
	 * @return
	 * 根据id查询记录
	 */
	public Department selectById(@Param("id")Long id);
	/**
	 * @param id
	 * @return
	 * 根据id查询记录
	 */
	public DepartmentDto selectDempNameById(@Param("id")Long id);
	/**
	 * @param staffId
	 * @return
	 * 根据id查询记录
	 */
	public DepartmentDto getPrincipal(@Param("staffId")Long staffId);
	
	/**
	 * @param staffId
	 * @return
	 *   获取一级部门信息
	 */
	public DepartmentDto getFirstDept(@Param("staffId")Long staffId);
	
	 /**
	 * 搜索 
	 * @param departmentDto blackWhiteList(搜索条件)
	 * @return 分页数据
	 */
	public List<Department> distinctOrgNum(@Param("departmentDto")DepartmentDto departmentDto);

    int updateByMerchantId2(DepartmentDto departmentDto);

	int editParent(@Param("mergeId")Long mergeId,@Param("acceptId")Long acceptId);

	List<Department> selectByName(@Param("departmentDto")DepartmentDto departmentDto);

	List<DepartmentDto> selectOrgAssistant(@Param("departmentDto")DepartmentDto departmentDto,@Param("beginNum")int beginNum,@Param("endNum")int endNum);

	int selectOrgAssistantCount(@Param("departmentDto")DepartmentDto departmentDto);

	List<Department> selectAgentDeptByDev(@Param("departmentDto")DepartmentDto departmentDto,@Param("devId") Long devId);

	List<Department> selectDeptByParents(@Param("parents")List<Department> departmentDto);

    DepartmentDto selectDeptByParent(@Param("departmentDto") DepartmentDto departmentDto);

	List<DepartmentDto> selectPrincipalNameByCompany(@Param("departmentDto") DepartmentDto departmentDto);
	
	List<Map<String, Object>> getPrincipalByPartnerId(Long partnerId);

	List<Department> selectListByPermissionCodes(@Param("departmentDto") DepartmentDto departmentDto);
}
